package com.szrt.java.day20161223.demo02;

import java.util.Scanner;

import org.junit.Test;

public class SwitchDemo01 {
	
	
	
	/**
	 * 你输入交通工具 我输出你的速度
	 *  == 230   高铁
	 *  == 120   小车
	 *  == 40     电动车
	 *  else    走路  11
	 *  
	 *  1: break break死都要写
	 *  2: byte/short/int/long/char/String
	 *  3: 不管写了多个个。会且只会执行1条语句
	 *  4: 等于的关系
	 * 
	 */
	
	@Test
	public void swithDemo02(){
		
		Scanner sc = new Scanner(System.in);
		
		System.out.println("请输入行驶速度");
		String tool=sc.next();
		sc.close();
		
		switch(tool){
			case "高铁":System.out.println(230);	    break;
			case "小车":System.out.println(120);	    break;
			case "电动车": System.out.println(40);	break;
			default: System.out.println(11);	    break;
		}
	}
	@Test
	public void swithDemo01(){
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入行驶速度");
		int speed=sc.nextInt();
		sc.close();
		
		switch (speed) {
			case 230:System.out.println("高铁");	    break;
			case 120:System.out.println("小车");	    break;
			case 40: System.out.println("电动车");	break;
			default: System.out.println("走路");	    break;
		}
	}
	@Test
	public void swithc00(){
		
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入行驶速度");
		byte speed=sc.nextByte();
		sc.close();
		
		switch (speed) {
		case 127:System.out.println("高铁");	    break;
		case 120:System.out.println("小车");	    break;
		case 40: System.out.println("电动车");	break;
		default: System.out.println("走路");	    break;
		}
	}
	@Test
	public void if01(){
		
		int speed=120;
		
		if(230==speed){
			System.out.println("高铁");
		}else if(120==speed){
			System.out.println("小车");
		}else if(40==speed){
			System.out.println("电动车");
		}else{
			System.out.println("走路");
		}
		
	}
	
	
	

}
